<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数求阶乘</title>
</head>
<body>
    <script>
        function JC(n){
            var num = 1;
            for(var i = 2; i<=n; i++){
                num *=i;
            }
            return num;
        } 
        document.write('3的阶乘是'+ JC(3));
        
        function Sum(n){
            var sum = 0;
            for(var i =1;i <=n;i++){
                sum += JC(i);
            }
            return sum;
        }
        document.write('3的阶乘累加和是' +Sum(3));
        
    </script>
</body>
</html>